﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>授权人列表</title>
    <script type="text/javascript" src="./Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="./Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="./Scripts/QueryString.js" type="text/javascript"></script>
    <script src="./Scripts/config.js" type="text/javascript"></script>
    <script src="./Comm/Gener.js?ver=123" type="text/javascript"></script>
    <link href="/DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <base target="_self" />
    <script language="javascript" type="text/javascript">
        /* ESC Key Down */
        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }

        //页面启动函数.横幅
        $(function () {

            $("#Msg").html("<img src=./Img/loading.gif />&nbsp;正在加载,请稍后......");

            InitPage();

            $("#Msg").html("");
        });

        //初始化数据.
        function InitPage() {

            var webUser = new WebUser();
            if (webUser.IsAuthorize == "1") {
                window.location.href = 'AuthorTodolist.htm';
                return;
            }

            var handler = new HttpHandler("BP.WF.HttpHandler.WF");
            var data = handler.DoMethodReturnString("AuthorList_Init");
            data = JSON.parse(data);

            if (data.length == 0) {
                $("#docs").html("");
                return;
            }

            var currDT = getNowFormatDate();

            var html = "<table style='width:90%;'>";
            html += "<tr>";
            html += "<th>授权人</th>";
            html += "<th>授权到日期</th>";
            html += "</tr>";

            for (var i = 0; i < data.length; i++) {
                var en = data[i];

                if (en.AuthorDate >= currDT)
                    html += "<tr><td><a href=\"javascript:LogAs('" + en.No + "','" + en.Name + "');\"> " + en.Name + "</a></td><td>" + en.AuthorDate + "</td></tr>";
                else
                    html += "<tr><td>  " + en.Name + " - <font color=red>授权逾期</font></td><td>" + en.AuthorDate + "</td></tr>";
            }
            html += "</table>";

            $("#docs").html(html);
        }

        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "-";
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            var currentdate = year + seperator1 + month + seperator1 + strDate;
            return currentdate;
        }

        function LogAs(fk_emp, empName) {

            if (window.confirm('您确定要以[' + empName + ']授权方式登陆处理工作吗？') == false)
                return;

            var handler = new HttpHandler("BP.WF.HttpHandler.WF");
            handler.AddPara("No", fk_emp);
            var data = handler.DoMethodReturnString("AuthorList_LoginAs");

            if (data.indexOf('err') == 0) {
                alert('授权登录失败! \t\n' + data);
                return;
            }

            window.location.href = 'AuthorTodolist.htm?RefNo=' + fk_emp;
            return;

            // parent.location.reload();
            //top.location.href = '../WF/App/Classic/index.jsp';
            //   top.location.href = './AuthorTodolist.htm';
            //window.open('Todolist.htm');
        }
    </script>
</head>
<body>
    <center>
        <table style="width: 50%;">
            <caption>
                授权人列表
            </caption>
            <tr>
                <td style=" padding:40px;">
                    <div id="docs" name="docs">
                    </div>
                </td>
            </tr>
        </table>
    </center>
</body>
</html>
